import request from '@/service/request'
import axios from 'axios'
import { BASE_URL, TIME_OUT } from '@/service/config'
//获取商品列表
// export function getGoodsList(params = {}) {
//   return request.post('/item/page', params)
// }

export function getGoodsList(params = {}) {
  return axios.post('/item/page', params, {
    baseURL: BASE_URL,
    timeout: TIME_OUT,
  })
}

//获取商品详情
export function getGoodDetail(id: string) {
  return request.get('/item/detail', {
    params: {
      id,
    },
  })
}
//获取商品管理详情
export function getGoodManageDetail(id: string) {
  return request.get('/item/manage/detail', {
    params: {
      id,
    },
  })
}

// 添加商品
export function addGoods(data: any) {
  return request.post('/item/add', data)
}
// 上架商品
export function releaseGoods(id: string, putawayNumber: number) {
  return request.post('/item/release', {
    id,
    putawayNumber,
  })
}
//下架商品
export function outGoods(id: string) {
  return request.post('/item/out', {
    id,
  })
}

//下单
export function orderGood(itemId: string, number: number) {
  return request.post('/order/place', { items: [{ itemId, number }] })
}

//支付
export function payGood(payId: string) {
  return request.get('/alipay/pay', {
    params: {
      payId,
    },
  })
}

//获取订单详情
export function orderDetail(orderId: string) {
  return request.get('/order/info', {
    params: {
      orderId,
    },
  })
}

//确认收获
export function rightOrder(id: string) {
  return request.post('/order/receiving', { id })
}

//评价
export function evaluate(id: string, content: string, score: string) {
  return request.post('/order/evaluation', { id, content, score })
}
